﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace RunnerX
{
    enum PlayerState
    {
        Running,
        Jumping,
        Falling,
        Dead
    }

    class Player
    {
        #region Fields and Properties

        private AnimatedSprite _sprite; // Player's animated sprite.

        // Location of the player on screen.
        private int _x = 100;
        private int _y = 260;
        public int X
        {
            get { return _x; }
            set { _x = value; }
        }
        public int Y
        {
            get { return _y; }
            set { _y = value; }
        }

        // Player state
        private PlayerState _state = PlayerState.Falling;
        public PlayerState State
        {
            get { return _state; }
            set { _state = value; }
        }

        // TODO: Physical state (physics)

        public Rectangle BoundingBox
        {
            get{return new Rectangle(_x, _y,
                RunnerConfig.PlayerSpriteSize.Width,
                RunnerConfig.PlayerSpriteSize.Height);}
        }

        #endregion

        #region Constructors

        public Player(Texture2D texture)
        {
            _sprite = new AnimatedSprite(texture, 0,64,
                                         RunnerConfig.PlayerSpriteSize.Width,
                                         RunnerConfig.PlayerSpriteSize.Height,
                                         RunnerConfig.PlayerAnimationFrameCount) {IsAnimating = true};
        }

        #endregion

        #region Update and Draw

        public void Draw(SpriteBatch sb)
        {
            _sprite.Draw(sb,_x, _y, false);
        }

        public void Update(GameTime gameTime)
        {
            _sprite.Update(gameTime);
        }

        #endregion
    }
}
